<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
<ul id="error_message_box"></ul>
<?php
echo form_open('staffs/update_payroll/'.$payroll->payroll_id,array('id'=>'update_form'));
?>
<fieldset id="item_basic_info">
<legend><?php echo $this->lang->line("staffs_payroll_info"); ?></legend>

<div class="field_row clearfix">	
<?php echo form_label($this->lang->line('staffs_basic_wage').':', 'basic_wages',array('class'=>'required wide')); ?>
	<div class='form_field'>
	<?php echo form_input(array(
		'name'=>'basic_wages',
		'id'=>'basic_wages',
		'value'=>$payroll->basic_wages)
	);?>
	</div>
</div>

<div class="field_row clearfix">	
<?php echo form_label($this->lang->line('staffs_tax_cat').':', 'tax_cat',array('class'=>'wide')); ?>
	<div class='form_field'>
	<?php echo form_dropdown('tax_cat', $taxs,$selected_tax);?>
	</div>
</div>

<div class="field_row clearfix">	
<?php echo form_label($this->lang->line('staffs_ssf_cat').':', 'ssf_cat',array('class'=>'wide')); ?>
	<div class='form_field'>
	<?php echo form_dropdown('ssf_cat', $ssfs,$selected_ssfs);?>
	</div>
</div>

<div class="field_row clearfix">
		<?php echo form_label($this->lang->line('date').':', 'payroll_date',array('class'=>'required wide')); ?>
		<div class='form_field'>
		<?php echo form_input(array(
		'name'=>'payroll_date',
		'id'=>'payroll_date',
		'value'=>$payroll->date)
		);?>
		
		<?php
			echo form_button(array(
			'name'=>'payroll_date_btn',
			'id'=>'payroll_date_btn',
			'class'=>'submit_button'),$this->lang->line('date')
			);
		?>
		</div>
		<script type="text/javascript">
                  new Calendar({
                          inputField: "payroll_date",
                          dateFormat: "%B %d, %Y",
                          trigger: "payroll_date_btn",
                          bottomBar: true,
						  showTime: false,
						  animation: true,
                          onSelect: function() {
                              this.hide();
                          }
						 });
                </script>
</div>


<fieldset id="item_basic_info">
<legend><?php echo $this->lang->line("staffs_allowances"); ?></legend>
<div class="field_row clearfix">	
<?php echo $manage_allowance ; ?>
</div>
</fieldset>

<fieldset id="item_basic_info">
<legend><?php echo $this->lang->line("staffs_deductions"); ?></legend>
<div class="field_row clearfix">	
<?php echo $manage_deductions ; ?>
</div>
</fieldset>
<input id="hidden_person" name="hidden_person" value="<?php echo $payroll->person_id; ?>" type="hidden">
<?php
echo form_submit(array(
	'name'=>'submit',
	'id'=>'submit',
	'value'=>$this->lang->line('common_submit'),
	'class'=>'submit_button float_right')
);
?>
</fieldset>
<?php 
echo form_close();
?>
<script type='text/javascript'>
//validation and submit handling
$(document).ready(function()
{	
	$('#update_form').validate({
		submitHandler:function(form)
		{
			$(form).ajaxSubmit({
			success:function(response)
			{
				tb_remove();
				post_item_form_submit(response);
			},
			dataType:'json'
		});

		},
		errorLabelContainer: "#error_message_box",
 		wrapper: "li",
		rules: 
		{
			basic_wages:"required",
			payroll_date:"required"
   		},
		messages: 
		{
			basic_wages:"<?php echo $this->lang->line('staffs_basic_wage_required'); ?>",
			payroll_date:"<?php echo $this->lang->line('staffs_payroll_date_required'); ?>"
		}
	});
});


function delete_allow_diduc(row_id,payroll_id,who)
{		
	var url = "<?php echo site_url("$controller_name/delete_allow_diduc")?>";
	$.post(url, { 'row_id': row_id,'payroll_id': payroll_id,'who': who },function(response)
	{
		tb_remove();
		post_item_form_submit(response);
		
	},"json");
}
	
</script>
